#include "TcpServer.h"
#include "TcpSocket.h"

class Buffer
{
public:
    char c[1024];
};

int main()
{

    TcpServer *tcpServer = new TcpServer();
    auto on_acce = [](TcpSocket *tcpSocket)
    {
        LOGI("in accept func %d", tcpSocket->m_connfd);
        while (1)
        {
            Buffer buf;
            int len = tcpSocket->Recv<Buffer>(&buf);
            if (len > 0)
            {
                LOGI("%s", buf.c);
            }
            else if (len == 0)
            {
                LOGI("len is Zero \nsocket end %d", tcpSocket->m_connfd);
                break;
            }
            else if (len < 0)
            {
                LOGI("len < 0 error", "");
                break;
            }
        }
    };
    tcpServer->SetOnAccept(on_acce);
    tcpServer->Listen(6668);

    return 0;
}